home *** CD-ROM | disk | FTP | other *** search
/ Amiga Format CD 12 / Amiga Format AFCD12 (Apr 1997, Issue 96).iso / -readerstuff- / manolis_pappas / mathfx / examples / logarithmic.c < prev    next >
Encoding:
C/C++ Source or Header  |  1997-01-29  |  1.1 KB  |  42 lines

  1. /* Illustration of logarithmic axes, and redefinition of window using */
  2. /* Windowing commands of MathFX library. */
  3. /* Copyright (©) 1995, The Xperts Group Inc. All Rights Reserved. */
  4. /* Author: Manolis S Pappas. */
  5.  
  6. #include <math.h>
  7.  
  8. main()
  9. {
  10.       int i;
  11.       float freql[101],ampl[101],phase[101];
  12.       float f0, freq;
  13.  
  14.       fxstar(1,1);
  15.       fxadv(0);
  16.       fxfont(2);
  17.  
  18.       f0 = 1000.0;
  19.       for (i=0; i<=100; i++) {
  20.         freql[i]=1.0+i/20.0;
  21.         freq= pow(10.0,freql[i]);
  22.         ampl[i]=20.0*log10(1.0/sqrt(1.0+pow((freq/f0),2.)));
  23.         phase[i]=-(180.0/3.141592654)*atan(freq/f0);
  24.       }
  25.  
  26.       fxvpor(0.15,0.85,0.1,0.9);
  27.       fxwind(1.0,6.0,-80.0,0.0);
  28.       fxbox("bclnst",0.0,0,"bnstv",0.0,0);
  29.       fxline(101,freql,ampl);
  30.       fxptex(5.0,-30.0,1.0,-20.0,0.5,"-20 dB/decade");
  31.       fxwind(1.0,6.0,-100.0,0.0);
  32.       fxbox(" ",0.0,0,"cmstv",30.0,3);
  33.       fxline(101,freql,phase);
  34.  
  35.       fxmtex("b",3.2,0.5,0.5,"Frequency");
  36.       fxmtex("t",2.0,0.5,0.5,"Single Pole Low-Pass Filter");
  37.       fxmtex("l",5.0,0.5,0.5,"Amplitude (dB)");
  38.       fxmtex("r",5.0,0.5,0.5,"Phase shift (degrees)");
  39.  
  40.       fxend();
  41. }
  42.